package march.test_3_4;

import java.util.Scanner;

public class TestMain2 {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            String str1 = sc.nextLine();
            String str2 = sc.nextLine();
            char[] ch1 = str1.toCharArray();
            char[] ch2 = str2.toCharArray();
            System.out.println(med(ch1, ch2));
        }
    }
    public static int med(char[] ch1, char[] ch2){
        int[][] arr = new int[ch1.length + 1][ch2.length + 1];
        int maxCount = 0;
        for(int i = 1; i < ch1.length + 1; i++){
            for(int j = 1; j < ch2.length + 1; j++){
                if(ch1[i-1] == ch2[j-1]){
                    arr[i][j] = arr[i-1][j-1] + 1;
                }
                if(maxCount < arr[i][j]){
                    maxCount = arr[i][j];
                }
            }
        }
        return maxCount;
    }

}
